let count=0;
export const genCallbackMap=({
    idPrefix='genCallbackMap_'
}={})=>{
    const cbMap = {};
    const add = (fn,opts) => {
        count++;
        const id = idPrefix+count;
        cbMap[id] ={
            fn,
            ...opts
        };
        return id;
    };
    const get=(id)=>{
        return cbMap[id];
    };
    const remove=(id)=>{
        return delete cbMap[id];
    };
    const getFn=(id)=>{
        const cb=cbMap[id];
        return cb&&cb.fn;
    };
    return {
        add,
        remove,
        get,
        getFn
    }
};
export default genCallbackMap;